package cn.kai.process.flow.node;

import cn.hutool.extra.spring.SpringUtil;
import cn.kai.process.flow.core.Node;
import cn.kai.process.flow.core.NodeContext;
import lombok.AllArgsConstructor;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

/**
 * 异步节点
 Author: cKnight
 Date: 2025/1/23
 */
@AllArgsConstructor
public class AsyncNode implements Node {
    private Node node;
    @Override
    public void execute(NodeContext context) {
        ThreadPoolTaskExecutor threadPoolTaskExecutor = SpringUtil.getBean("threadPoolTaskExecutor", ThreadPoolTaskExecutor.class);
        threadPoolTaskExecutor.execute(()-> node.exe(context));
    }
}
